// app.js
const network = require("/utils/network.js")
App({
    onLaunch() {

        const accountInfo = wx.getAccountInfoSync();
        switch (accountInfo.miniProgram.envVersion) {
            case 'develop':
                this.globalData.envVersion = 0; // 开发版
                break;
            case 'trial':
                this.globalData.envVersion = 1; // 体验版
                break;
            case 'release':
                this.globalData.envVersion = 2; // 正式版
                break;
            default:
                break;
        }

        const token = wx.getStorageSync('token');
        if (!token) {
            wx.redirectTo({
                url: '/pages/login/index',
            })
        }
    },
    api: {
        doLogin: 'login/sign-in', //登录
        queryRights: 'login/query-rights', //查询权限
        distanceList: 'media-point/list-distance', // 查询距离待选项
        areaList: 'media-point/list-area', // 所有行政区划
        industryList: 'media-point/list-industry', // 所有行业 废弃
        sourceList: 'media-point/list-source', // 所有资源
        myCustomerList: 'media-point/list-my-customers', // 我跟进的客户
        allMediaTypeList: 'media-point/list-all-media-type', // 所有媒体类型
        searchBuilding: 'media-point/search-building', // 查询符合条件的项目
        buildingDetail: 'media-point/building-detail', // 项目详情
        submitCustomerNeed: 'media-point/submit-customer-need', // 提交客户需求
        customerNeedList: 'media-point/customer-need-list', // 我的客户需求列表
        exportData: 'media-point/export-data', // 导出数据
        searchMap: 'sale_intention_order/search', //地图筛选

        flowToCheck: 'personal_handle/to_check_list', // 待办提醒-待我审批列表
        flowProcessing: 'personal_handle/processing_list', // 待办提醒-申请中列表
        flowFinished: 'personal_handle/finished_list', // 待办提醒-已通过列表
        flowBack: 'personal_handle/back_list', // 待办提醒-被退回列表
        flowDraft: 'personal_handle/draft_list', // 待办提醒-草稿箱列表
        flowDelete: 'personal_handle/delete_list', // 待办提醒-回收站列表
        flowChecked: 'personal_handle/checked_list', // 待办提醒-审批记录列表
        flowCheckHistory: 'personal_handle/check_history2', // 审批历史

        offerQuery: 'offer/query', // 报价查询
        saleMonthCur: 'saleMonth/queryThisMonthTarget', // 本月盘点
        saleMonthNext: 'saleMonth/nextMonthTarget', // 下月计划
        customerOpenSea: 'customer/pool/public/sea', // 公海
        customerOpenSeaCheckRecord: 'customer/pool/check/record/page', // 公海-申请跟进记录
        customerOpenSeaApplyFollow: 'customerApplyFollowRecord/apply',  // 公海-申请跟进
        customerOpenSeaApplyFollowPass: 'customerApplyFollowRecord/pass',  // 公海-申请跟进-通过
        customerOpenSeaApplyFollowUnpass: 'customerApplyFollowRecord/reject',  // 公海-申请跟进-驳回
        customerMy: 'customerInfo/page', //我的客户
        contractMy: 'contractApply/list', //我的合同
        followListByCustomerId: 'customerInfo/visitRecordList',// 根据客户id获取拜访记录
        getCustomerDetail: 'customerInfo/one',// 获取详情

        contractSave: 'contractApply/save', // 合同-保存
        contractBegin: 'contractApply/begin', // 合同-提交
        contractPass: 'contractApply/pass', // 合同-通过
        contractReturnBack: 'contractApply/return_back', // 合同-退回
        contractDelete: 'contractApply/delete', // 合同-删除
        contractActualDelete: 'contractApply/actual_delete', // 合同-彻底删除

        getSubordinateUser: 'user/getSubordinateUser',// 获取部门下属员工信息
        userListByCode: 'user/list_by_role_code', // 根据角色编码，获取用户
        actionList: 'action/list',// 动作字典
        customerList: 'customerInfo/list-all',// 获取我的客户待选项
        partAHistoryList: 'contractApply/part_a_history',// 甲方名称历史待选项
        companyList: 'department/get_company',// 子公司待选项
        mediaSpecList: 'media/type-spec/list-type-spec-by-media-type-id',// 媒体规格待选项
        contractDetail: 'contractApply/detail', // 合同详情
        saleOrderMy: 'bill_sale/list',// 我的销售单
        marketOrderMy: 'bill-market/list',// 我的市场单
        designList: 'bill-market/designList',//设计人员
        contractListByCustomerId: 'contractApply/list-latest-by-customer-id',// 根据客户id获取合同
        saleOrderListByContractId: 'bill_sale/list-for-market-by-contract-id',// 根据合同id获取销售单
        planListById: 'bill_sale/list-by-related',// 根据合同id获取锁位列表
        advanceList: 'customerInfo/advanceList',// 我的客户推进动作集合
        signatureHistoryList: 'saleMonth/signatureHistoryList',// 获取签约记录
        visitCommentsPage: 'customerInfo/visitCommentsPage',// 获取历史批注
        getDictData: 'common/dict/list_all3rd_bycode',// 获取字典数据
        allUserList: 'common/user/allUserList',// 所有的用户列表
        saveCustomer: 'customerInfo/save',// 临时保存客户信息
        submitCustomer: 'customerInfo/saveAndStartFlow',// 提交客户信息进入审核
        customerDetail: 'customerInfo/flow/one',// 获取审核详情
        customerInfoDetail: 'customerInfo/one',// 获取客户详情
        customerCheck: 'customerInfo/check',// 审核方法
        customerDel: 'customerInfo/remove',// 删除
        customerActualDelete: 'customerInfo/actualDelete',// 彻底删除
        getContactInfoById: 'customerInfo/getContactInfoById',// 获取客户联系人信息
        getPutStorageById: 'customerInfo/getPutStorageById', // 获取客户入库信息
        getContactById: 'customerInfo/getContactById',// 获取联系人名称数组
        addVisitRecord: 'saleMonth/addVisitRecord',// 添加跟进记录
        addContract: 'customerInfo/add/linkUser',// 添加客户联系人
        addPutStorage: 'customerInfo/add/putStorage', // 添加客户入库信息
        editDetail: 'customerInfo/edit/detail',// 获取修改详情
        editSubmit: 'customerInfo/edit/submit', // 提交修改客户信息
        editSave: 'customerInfo/edit/save', // 保存修改客户信息
        editPass: 'customerInfo/edit/pass', // 通过修改客户信息
        relieve: 'customer/pool/relieve',//解除维护
        editReturnBack: 'customerInfo/edit/returnBack', // 驳回修改客户信息
        editDel: 'customerInfo/edit/remove', // 删除修改客户信息
        editActualDelete: 'customerInfo/edit/actualDelete', // 彻底删除修改客户信息
        media_type_count_amount: 'bill_sale/media_type_count_amount',// 获取刊例总价
        assign: 'customerInfo/edit',// 指派销售
        billSaleSave: 'bill_sale/save', // 销售单-保存
        billSaleBegin: 'bill_sale/begin', // 销售单-提交
        billSalePass: 'bill_sale/pass', // 销售单-通过
        billSaleReturnBack: 'bill_sale/return_back', // 销售单-退回
        billSaleDelete: 'bill_sale/delete', // 销售单-删除
        billSaleActualDelete: 'bill_sale/actual_delete', // 销售单-彻底删除
        billSaleDetail: 'bill_sale/detail',// 销售单详情',

        billMarketSave: 'bill-market/save', // 销售单-保存
        billMarketBegin: 'bill-market/begin', // 销售单-提交
        billMarketPass: 'bill-market/pass', // 销售单-通过
        billMarketReturnBack: 'bill-market/return_back', // 销售单-退回
        billMarketDelete: 'bill-market/delete', // 销售单-删除
        billMarketActualDelete: 'bill-market/actual_delete', // 销售单-彻底删除
        billMarketDetail: 'bill-market/detail',// 销售单详情'

        getMediaTypeArrBySaleId: 'bill_sale/getMediaTypeArrBySaleId',// 根据销售单ID获取媒体类型数组
        getYearWeekList: 'saleMonth/yearWeek/list',// 根据客户id获取签约时间
        addSigningTime: 'saleMonth/addSigningTime',// 添加签约预估
        addNextVisitDate: 'customerInfo/addNextVisitDate',// 添加下次拜访时间
        confirmReceive: 'saleMonth/confirmReceive',// 确认收到
        querySaleYearTargetSummary: 'saleMonth/querySaleYearTargetSummary',// 查询销售半年目标
        queryCompanyMonthByMonth: 'saleMonth/queryCompanyMonthByMonth',// 查询公司月度目标
        queryCompanyMonthPlanByMonth: 'saleMonth/queryCompanyMonthPlanByMonth',// 查询公司下月计划
        companyAdvanceList: 'customerInfo/companyAdvanceList',// 公司月度客户推进进度表
        fillAnnotation: 'saleMonth/fillAnnotation',// 填写批租
        fillReasonsForNotCooperating: 'saleMonth/fillReasonsForNotCooperating',// 填写未成交原因
        queryCompanyYearTargetSummary: 'saleMonth/queryCompanyYearTargetSummary',// 查询年度汇总
    },

    globalData: {
        appid: 'wx96cc54c8c562b617',
        envVersion: 0,
        mapKey: 'GLVBZ-EMJCD-5VN4C-HF3T4-UKADS-LTB7Q',
        mapReferer: '美莱小程序',
        userInfo: null,
        reg_idcard: /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/,
        reg_mobile: /^1(3|4|5|6|7|8|9)\d{9}$/,
        reg_tel: /^((\d{3,4})|\d{3,4}-|\d{3,4}(\s*))?\d{7,8}$/
    }
})
